//define(function(require, exports, module) {
	/***提示框
	 * config={
	 * 		id:'', //required
	 * 		yesText:'确定', //option
			noText:'关闭',//option
			title:'提示',//option
			
			type:'sure',//option ''sure|yesno',
			width:'500px',//option
			content:'',//option
			contentType:'text',//option 'html|text'
			onSure:function(commandData){},//option
			onCancel:function(commandData){},
			commandData:{}//option
	 * }
	 */
	var TipDlg=function(config){
		var _config={
			yesText:'确定',
			noText:'关闭',
			title:'提示',
			
			type:'sure',
			width:'500px',
			content:'',
			contentType:'text',
			onSure:function(commandData){},
			onCancel:function(commandData){},
			commandData:{}
		};
		this.oldConfig={};
		$.extend(true,_config,config);
		$.extend(true,this,_config);
		this.init();
	}
	
	TipDlg.prototype={
		init:function(){
			this.render();
			this.refined(this);
			this.bind();
		},
		render:function(){
			var html=[];
			html.push('<div class="modal fade " data-backdrop="static" id="'+this.id+'" tabindex="-1" role="dialog" aria-labelledby="TipDlg-'+this.id+'" >');
			html.push('  <div class="modal-dialog" >');
			html.push('    <div class="modal-content">');
			html.push('      <div class="modal-header">');
			html.push('        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>');
			html.push('        <h4 class="modal-title" ></h4>');
			html.push('      </div>');
			html.push('      <div class="modal-body"></div>');
			html.push('      <div class="modal-footer">');
			html.push('          <button type="button" class="btn btn-tip btn-close"></button>');
			html.push('      	  <button type="button" class="btn btn-tip btn-default"></button>        ');
			html.push('      </div>');
			html.push('    </div><!-- /.modal-content -->');
			html.push('  </div><!-- /.modal-dialog -->');
			html.push('</div><!-- /.modal -->');
			$('body').append(html.join(''));
			this.$id=$('#'+this.id);
			this.$dlg=this.$id.find('.modal-dialog');
			this.$title=this.$id.find('.modal-title');
			this.$content=this.$id.find('.modal-body');
			this.$yes=this.$id.find('.btn-default');
			this.$no=this.$id.find('.btn-close');
			this.$close=this.$id.find('.close');},
		bind:function(){
			var that=this;
			//确定按钮
			this.$yes.on('click',function(){
				that.onSure&&that.onSure(that.commandData);
				//关闭窗口
				that.$id.modal('hide');
				
			});
			//关闭按钮
			this.$no.on('click',function(){
				that.onCancel&&that.onCancel(that.commandData);
				//关闭窗口
				that.$id.modal('hide');
			});
			//关闭按钮
			this.$close.on('click',function(){
				that.onCancel&&that.onCancel(that.commandData);
				//关闭窗口
				that.$id.modal('hide');
			});
			//隐藏框后的操作
			this.$id.on('hidden.bs.modal', function (e) {
				$.extend(true,that,that.oldConfig);
			})
		},
		/**根据配置，对dom进一步调整*/
		refined:function(config){
			/** yesText:'确定',*/
			config.yesText&&this.$yes.html(config.yesText);
			/**noText:'关闭',*/
			config.noText&&this.$no.html(config.noText);
			/**title:'提示',*/
			config.title&&this.$title.html(config.title);
			/**type:'sure',*/
			if(config.type)
				config.type=='sure'?this.$no.css('display','none'):this.$no.css('display','inline-block');
			/**width:'500px',*/
			config.width&&this.$dlg.css('width',config.width);
			/**content:'',contentType:'html|text',*/
			if(config.content)
				config.contentType=='html'?this.$content.html(config.content):this.$content.text(config.content);
		},
		/***config={
			type:'sure|yesno',
			width:'500px',
			content:'',
			contentType:'html|text',
			onSure:function(commandData){},
			onCancel:function(commandData){},
			commandData:{}
		 * }*/
		show:function(config){
			this.oldConfig={
				type:this.type,
				width:this.width,
				content:this.content,
				contentType:this.contentType,
				onSure:this.onSure,
				commandData:this.commandData
			};
			$.extend(true,this,config);
			this.refined(config);
			this.$id.modal('show');
		}
	};
	
	window['TipDlg']=TipDlg;
	
//});